unit EditUnionComp;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics,
  Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses,
  uniGUIClasses, uniGUIForm, DB, uniMemo, uniDBMemo, uniButton, uniBitBtn,
  uniEdit, uniDBEdit, dxGDIPlusClasses, uniLabel, jpeg, uniGUIBaseClasses,
  uniImage, uniMultiItem, uniComboBox, uniDBComboBox;

type
  TFrmEditUnionComp = class(TUniForm)
    UniImage8: TUniImage;
    lbCaption: TUniLabel;
    edUniName: TUniDBEdit;
    edAccountNo: TUniDBEdit;
    UniLabel2: TUniLabel;
    edContactor: TUniDBEdit;
    UniLabel3: TUniLabel;
    edTel: TUniDBEdit;
    btSave: TUniBitBtn;
    btClose: TUniBitBtn;
    UniLabel4: TUniLabel;
    UniLabel5: TUniLabel;
    UniLabel1: TUniLabel;
    UniLabel6: TUniLabel;
    UniLabel7: TUniLabel;
    moSrvScope: TUniDBMemo;
    edCity: TUniDBEdit;
    dsUnionComp: TDataSource;
    cbNode: TUniDBComboBox;
    UniLabel8: TUniLabel;
    cbUniGroup: TUniDBComboBox;
    UniLabel9: TUniLabel;
    cbBlcType: TUniDBComboBox;
    btFind: TUniBitBtn;
    procedure btSaveClick(Sender: TObject);
    procedure btCloseClick(Sender: TObject);
    procedure cbNodeCloseUp(Sender: TObject);
    procedure UniFormShow(Sender: TObject);
    procedure cbBlcTypeCloseUp(Sender: TObject);
    procedure cbUniGroupCloseUp(Sender: TObject);
    procedure btFindClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure Initform;
  end;

function FrmEditUnionComp: TFrmEditUnionComp;

implementation

{$R *.dfm}

uses
  MainModule, uniGUIApplication,BaseModule,dictmodule, FindAccount;

function FrmEditUnionComp: TFrmEditUnionComp;
begin
  Result := TFrmEditUnionComp(UniMainModule.GetFormInstance(TFrmEditUnionComp));
end;

procedure TFrmEditUnionComp.btCloseClick(Sender: TObject);
begin
  dmbase.crsUnion.Cancel;
  self.Close;
end;

procedure TFrmEditUnionComp.btFindClick(Sender: TObject);
begin
  frmfindaccount.SetDataset(dmbase.crsUnion);
  frmfindaccount.ShowModal;
end;

procedure TFrmEditUnionComp.btSaveClick(Sender: TObject);
begin
  dmbase.crsUnion.ApplyUpdates;
  self.Close;
end;

procedure TFrmEditUnionComp.cbBlcTypeCloseUp(Sender: TObject);
begin
  dsUnionComp.DataSet.FieldByName('BLC_TYPE').AsInteger := cbBlcType.ItemIndex + 1;
end;

procedure TFrmEditUnionComp.cbNodeCloseUp(Sender: TObject);
var
  nodename:String;
begin
  nodename := cbnode.Text;
  if dmdict.crsNode.Locate('node_name',nodename,[]) then
  begin
    dsUnionComp.DataSet.Edit;
    dsUnionComp.DataSet.FieldByName('NODE_NO').AsString := dmdict.crsNode.FieldByName('NODE_NO').AsString;
  end;
end;

procedure TFrmEditUnionComp.cbUniGroupCloseUp(Sender: TObject);
begin
  if dmdict.crsGroup.Locate('WEB_CAPTION',cbUniGroup.Text,[]) then
  begin
    dsUnionComp.DataSet.FieldByName('UNI_GPCODE').AsString := dmdict.crsGroup.FieldByName('web_name').AsString;
  end;
end;

procedure TFrmEditUnionComp.Initform;
begin
  if cbNode.Items.Count = 0 then
    cbNode.Items := dmdict.GetFiledList('sys_group_node','node_name');
  if cbUniGroup.Items.Count = 0 then
    cbUniGroup.Items := dmdict.GetFiledList('SYS_WEB','WEB_CAPTION');
end;

procedure TFrmEditUnionComp.UniFormShow(Sender: TObject);
begin
  Initform;
end;

end.
